package com.joinlabs.entity;

public class PageBean {
	private int page;	//第几页
	private int limit;	//一页数量
	private int totalCount;	//总数量
	private int totalPage;	//总页数
	private int startIndex;	//开始下标
	private int endIndex;	//结束下标
	public PageBean() {
		super();
	}
	public int getPage() {
		return page;
	}
	public void setPage(int page) {
		this.page = page;
	}
	public int getLimit() {
		return limit;
	}
	public void setLimit(int limit) {
		this.limit = limit;
	}
	public int getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public int getStartIndex() {
		return startIndex;
	}
	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}
	public int getEndIndex() {
		return endIndex;
	}
	public void setEndIndex(int endIndex) {
		this.endIndex = endIndex;
	}
	@Override
	public String toString() {
		return "PageBean [page=" + page + ", limit=" + limit + ", totalCount=" + totalCount + ", totalPage=" + totalPage
				+ ", startIndex=" + startIndex + ", endIndex=" + endIndex + "]";
	}
	public void calc(int totalCount) {
		
		this.totalCount = totalCount;
		
		this.totalPage = totalCount%limit == 0 ? totalCount/limit:totalCount/limit+1;
		
		this.startIndex = (page-1)*limit;
		
		this.endIndex = startIndex + limit;
		
		
	}
}
